package com.power.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.power.domain.ProdTagReference;
import com.power.service.ProdTagReferenceService;
import com.power.mapper.ProdTagReferenceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
* @author dingchunlin
* @description 针对表【prod_tag_reference】的数据库操作Service实现
* @createDate 2024-07-10 15:12:14
*/
@Service
public class ProdTagReferenceServiceImpl extends ServiceImpl<ProdTagReferenceMapper, ProdTagReference> implements ProdTagReferenceService{

    @Autowired
    private ProdTagReferenceMapper prodTagReferenceMapper;


    /**
     * 根据产品ID查询标签ID列表
     *
     * @param prodId 产品ID
     * @return 标签ID列表
     */
    @Override
    public List<Long> selectTagIdByProdId(Long prodId) {
        List<ProdTagReference> tagReferenceList = prodTagReferenceMapper.selectList(new LambdaQueryWrapper<ProdTagReference>()
               .eq(ProdTagReference::getProdId, prodId));
        List<Long> longList = tagReferenceList.stream()
                .map(ProdTagReference::getTagId).collect(Collectors.toList());
        return longList;
    }
}




